<?php
/**
 * User: taodf
 * Date: 17-4-29
 * Time: 下午8:32
 */

namespace Zeus\Routing;

use Zeus\Routing\Engines\FastRouteEngine;
use Zeus\Routing\Exceptions\NotSupportedRouterEngineException;

/**
 * 路由引擎的构造工厂
 *
 * Class RouterFactory
 * @package Zeus\Routing
 */
abstract class RouterFactory
{
    /**
     * 系统内部支持的路由引擎
     */
    const Engines=[
        "fastroute"=>FastRouteEngine::class,
    ];

    /**
     * 路由引擎的创建方法
     *
     * @param string $name
     * @return mixed
     * @throws NotSupportedRouterEngineException
     */
    public static function createRouter($name="FastRoute")
    {
        $name=strtolower($name);
        if(!array_key_exists($name, self::Engines)){
            throw new NotSupportedRouterEngineException();
        }
        $class=self::Engines[$name];

        return new $class();
    }
}